package com.weixing.mall.provider.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
import com.weixing.mall.provider.model.excel.*;
import com.weixing.mall.provider.model.vo.AfterSaleProblemVo;
import com.weixing.mall.provider.model.vo.KefuAuditOrderVo;
import com.weixing.mall.provider.model.vo.OrderListPCVo;
import com.weixing.mall.provider.model.vo.OutOfStockCancelOrderVo;
import com.weixing.mall.provider.service.IOrderExcalService;
import com.weixing.mall.util.SKUUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderExcalServiceImpl implements IOrderExcalService {

    @Override
    public List<OrderListPCED> switchTypeOrderListPCED(List<OrderListPCVo> source){
        List<OrderListPCED> target = Lists.newArrayList();
        source.forEach( s ->{
            OrderListPCED t = new OrderListPCED();
            BeanUtils.copyProperties(s,t);
            if(ObjectUtil.isNotEmpty(s.getProductSkuDesp())){
                t.setColor(SKUUtils.color2(s.getProductSkuDesp()));
                t.setSize(SKUUtils.size2(s.getProductSkuDesp()));
            }
             t.setGoodsSn(s.getGoodsSn()+"-"+s.getMarketPrice());
            target.add(t);
        });
        return target;
    }

    @Override
    public List<AfterSaleProblemED> switchTypeAfterSaleProblemED(List<AfterSaleProblemVo> source){
        List<AfterSaleProblemED> target = Lists.newArrayList();
        source.forEach( s ->{
            AfterSaleProblemED t = new AfterSaleProblemED();
            BeanUtils.copyProperties(s,t);
            if(ObjectUtil.isNotEmpty(s.getProductSkuDesp())){
                t.setColor(SKUUtils.color2(s.getProductSkuDesp()));
                t.setSize(SKUUtils.size2(s.getProductSkuDesp()));
            }
            target.add(t);
        });
        return target;
    }

    @Override
    public List<KefuAuditOrderED> switchTypeKefuAuditOrderED(List<KefuAuditOrderVo> source) {
        List<KefuAuditOrderED> target = Lists.newArrayList();
        source.forEach( s ->{
            KefuAuditOrderED t = new KefuAuditOrderED();
            BeanUtils.copyProperties(s,t);
            if(ObjectUtil.isNotEmpty(s.getProductSkuDesp())){
                t.setColor(SKUUtils.color2(s.getProductSkuDesp()));
                t.setSize(SKUUtils.size2(s.getProductSkuDesp()));
            }
            target.add(t);
        });
        return target;
    }

    @Override
    public List<OutOfStockCancelOrderED> switchTypeOutOfStockCancelOrderED(List<OutOfStockCancelOrderVo> source) {
        List<OutOfStockCancelOrderED> target = Lists.newArrayList();
        source.forEach( s ->{
            OutOfStockCancelOrderED t = new OutOfStockCancelOrderED();
            BeanUtils.copyProperties(s,t);
            if(ObjectUtil.isNotEmpty(s.getProductSkuDesp())){
                t.setColor(SKUUtils.color2(s.getProductSkuDesp()));
                t.setSize(SKUUtils.size2(s.getProductSkuDesp()));
            }
            target.add(t);
        });
        return target;
    }

    @Override
    public List<KefuAuditOrderAllED> switchTypeKefuAuditOrderAllED(List<KefuAuditOrderVo> source) {
        List<KefuAuditOrderAllED> target = Lists.newArrayList();
        source.forEach( s ->{
            KefuAuditOrderAllED t = new KefuAuditOrderAllED();
            BeanUtils.copyProperties(s,t);
            if(ObjectUtil.isNotEmpty(s.getProductSkuDesp())){
                t.setColor(SKUUtils.color2(s.getProductSkuDesp()));
                t.setSize(SKUUtils.size2(s.getProductSkuDesp()));
            }
            t.setAddrDetails(s.getProvince() + s.getCity() + s.getRegion() + s.getAddrDetail());
            target.add(t);
        });
        return target;
    }

}
